//
//  WanList.swift
//  YeKa
//
//  Created by Gina on 15/10/16.
//  Copyright © 2015年 Gina. All rights reserved.
//

import UIKit

class WanList: NSObject {
    
    var title: String?
    var picture: String?
    var url: String?
    var introduce: String?
    var voteCount: Int = 0
    
    init(dict: [String: AnyObject]) {
        super.init()
        setValuesForKeysWithDictionary(dict)
    }
    
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {}
    
    class func loadWanList(finished: (dataList: [WanList]?, error:NSError?) -> ()){
        let urlString = "diversion?accountId=&page=1&size=20"
        NetworkTools.sharedNetworkTools.request(YeKaNetworkMethod.GET, urlString: urlString, params: nil) { (result, error) -> () in
            
            if error != nil {
                finished(dataList: nil, error: error)
                return
            }
            
             if let array = result?["data"]?["list"] as? [[String: AnyObject]] {
                var list = [WanList]()
                for dict in array {
                    list.append(WanList(dict: dict))
                }
                finished(dataList: list, error: nil)
            }else{
                finished(dataList: nil, error: nil)
            }
        }
            
        
        
    }
    
    
   

}
